package cn.ztuo.bitrade.util;

import cn.ztuo.bitrade.entity.Coin;
import cn.ztuo.bitrade.entity.ExchangeCoin;
import cn.ztuo.bitrade.service.CoinService;
import cn.ztuo.bitrade.service.ExchangeCoinService;
import cn.ztuo.bitrade.service.ExchangeOrderService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

import javax.annotation.PostConstruct;
import java.util.List;

@Slf4j
@Component
public class ExchangeUtils {

    @Autowired
    private RedisUtil redisUtilDouble;
    @Autowired
    private ExchangeOrderService orderServiceDouble;
    @Autowired
    private ExchangeCoinService exchangeCoinServiceDouble;
    @Autowired
    private CoinService coinServiceDouble;

    private static ExchangeOrderService orderService;
    private static ExchangeCoinService exchangeCoinService;
    private static RedisUtil redisUtil;
    private static CoinService coinService;


    @PostConstruct
    public void init() {
        orderService = orderServiceDouble;
        redisUtil = redisUtilDouble;
        exchangeCoinService = exchangeCoinServiceDouble;
        coinService = coinServiceDouble;
    }

    public static List<ExchangeCoin> findExchangeCoins(){
        return exchangeCoinService.findAllEnabled();
    }
    public static ExchangeCoin getExchangeCoin(String symbol){
        return exchangeCoinService.findBySymbol(symbol);
    }
    public static Coin getCoinByUnit(String unit){
        return coinService.findByUnit(unit);
    }
    public static ExchangeCoinService getExchangeCoinService(){return exchangeCoinService;};
    public static ExchangeOrderService getExchangeOrderService(){return orderService;};

}
